<%@ page language="java" contentType="text/html; charset=utf-8"

	pageEncoding="utf-8"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>创建合同</title>
<link rel="stylesheet" type="text/css" href="css/css.css" />
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery.autocomplete.js"></script>
<script type="text/javascript" src="js/crlCheckCommons.js"></script>
<script type="text/javascript" src="js/calendar/WdatePicker.js"></script>
<link rel="stylesheet" href="css/jquery.autocomplete.css" />
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="css/font-awesome.min.css" rel="stylesheet" />
<link href="css/animate.css" rel="stylesheet" />
<link href="css/plugins/summernote/summernote.css" rel="stylesheet" />
<link href="css/plugins/summernote/summernote-bs3.css" rel="stylesheet" />
<link href="css/style.css" rel="stylesheet" />
<style>
.bor {
	border: 0px solid #ccc;
}

#emptable td {
	border: none !important;
}

td {
	margin: 0;
	padding-left: 16px;
	border: none;
	text-align: left;
}

.td {
	font-size: 16px;
	border: none;
	text-align: right;
}

#button {
	border-radius: 10px;
	margin-left: 10px;
	width: 135px;
	height: 30px;
	border: none;
	font-size: 16px;
	color: #fff;
	background-color: #47a4e1;
}

.form-body .col-md-6, .form-body .col-md-12 {
	min-height: 400px;
}

#apro, #bpro, #cpro {
	display: none;
}

#baBodysubmit {
	padding-left: 90px;
	margin-top: 0;
}
</style>
</head>
<body style="background: white">
	<script type="application/javascript">
		
		  
      var names ; //定义数据  
      //开始函数  
      $().ready(function(){  
        $.ajax({  
          type:'POST',  
          contentType: "application/json",  
          url: "checkoid.do",  
          dataType: "json",  
          success:function(data){  
            names = data;  
            autocompleteFn(names);  
          }  
        });  
      });  
       //自动 补全方法  
       function autocompleteFn(names){  
         $("#autoComplete").autocomplete(names,{  
           minChars:1,  
           max: 5,  
           dataType:"json",  
           autoFill: true,  
           mustMatch: true,  
           matchContains: true,  
           scrollHeight: 220,
           formatItem: function(data, i, total) {  
             return "<I>"+data.name+"</I>";  
           },  
           formatMatch: function(data, i, total) {  
             return data.name;  
           },  
           formatResult: function(data) {  
             return data.name;  
           }  
         }).result(function(event,data){
        	 $("#cname").html(data.cname);
        	 $("#cename").html(data.cename);
        	 $("#oid").val(data.oid);
         });  
       }  

	
	</script>
	<div id="pageAll">
		<div class="pageTop">
			<div class="page">
				<img src="img/coin02.png" /> <span><a href="main.do">首页</a>&nbsp;-&nbsp;
					<a href="contractmanage.do">合同管理</a>&nbsp;-&nbsp;合同添加</span>
			</div>
		</div>
		<div class="page ">
			<!-- 上传广告页面样式 -->
			<div class="banneradd bor">
				<form:form action="contractmanage_add.do" method="post" id="form" enctype="multipart/form-data"
					modelAttribute="contract"  onsubmit="return checkform()">
					<div class="baTopNo">
						<span>基本信息</span>
					</div>
					<div class="baBody">
						<div class="row form-body form-horizontal m-t">
							<div class="col-sm-6">
								<div class="ibox float-e-margins">
									<div class="col-md-12">
										<div class="form-group">
											<label class="col-sm-3 control-label">合同名称：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="name" class="form-control"
													id="oname" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">机构名称：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text"  class="form-control" id="autoComplete" />
													<span class="help-block m-b-none"></span>
													 <input type="hidden" name="oid" id="oid" />
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label" for="-NaN">购买产品类别：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<label class="checkbox-inline" for="atype"> <input
													type="checkbox" value="1" id="atype" name="aproduct" />网站专区
												</label> <label class="checkbox-inline" for="btype"> <input
													type="checkbox" value="1" id="btype" name="bproduct" />微刊
												</label> <label class="checkbox-inline" for="ctype"> <input
													type="checkbox" value="1" id="ctype" name="cproduct" />微博</label>
											</div><span class="help-block m-b-none"></span>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">服务方式：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<label class="radio-inline"> <input type="radio"
													value="1" name="servicetype" checked="checked" />镜像
												</label> <label class="radio-inline"> <input type="radio"
													value="2" name="servicetype" />远程
												</label>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">合同性质：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<select class="form-control" name="purpose">
													<option value="1" selected="selected">新增</option>
													<option value="2">正式</option>
													<option value="3">已签</option>
													<option value="4">续约</option>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">合同类型：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<select class="form-control" name="contracttype">
													<option value="1" selected="selected">销售</option>
													<option value="2">采购</option>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">合同经办人：</label>
											<div class="col-sm-9">
												<p class="form-control-static" id="cename">这里是纯文字信息</p>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">合同联系人：</label>
											<div class="col-sm-9">
												<p class="form-control-static" id="cname">这里是纯文字信息</p>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">合同总金额：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="amount" id="amount"
													class="form-control" /> <span class="help-block m-b-none"></span>

											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">付款方式：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<select class="form-control" name="paytype">
													<option value="1" selected="selected">一次性付款</option>
													<option value="2">按年支付</option>
													<option value="3">分期付款</option>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">签约日期：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="signdate" id="signdate"
													readonly="readonly" onclick="WdatePicker()" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">截止日期：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="deadline" id="deadline"
													readonly="readonly" onclick="WdatePicker()" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">合同日期：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="begindate" id="begindate"
													readonly="readonly" onclick="WdatePicker()" /><span class="help-block m-b-none"></span> 至 <input
													type="text" name="enddate" id="enddate" readonly="readonly"
													onclick="WdatePicker()" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">审核状态：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<select class="form-control" name="checkstate">
													<option value="1" selected="selected">未审核</option>
													<option value="2">审核中</option>
													<option value="3">已审核</option>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">甲方签字人：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="aset" id="aset"
													class="form-control" /> <span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">乙方签字人：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="bset" id="bset"
													class="form-control" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">合同扫描件：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="file" name="myfile" id="file"
													class="form-control" />
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">备注信息：</label>
											<div class="col-sm-9">
												<textarea rows="5" cols="40" name="remark"></textarea>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>	
					<!-- 
					<span>产品信息</span>		
					<!-- ABC产品 -->	
								<!-- A产品 -->
				<div id="apro">
					<div class="baTopNo" >
						<span>网站专区 </span>
					</div>
					<div class="baBody" >
						<div class="row form-body form-horizontal m-t">
							<div class="col-sm-6">
								<div class="ibox float-e-margins">
									<div class="col-md-12">
										<div class="form-group">
											<label class="col-sm-3 control-label" for="-NaN">网站功能：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<label class="checkbox-inline" for="netfunction"> 
												<input 	type="checkbox" value="1" id="netfunction"
													name="producta.netfunction" checked="checked" />期刊</label> <label
													class="checkbox-inline" for="netfunction" > <input
													type="checkbox" value="2" id="netfunction"
													name="producta.netfunction" />多媒 体</label> <label
													class="checkbox-inline" for="netfunction" > <input
													type="checkbox" value="3" id="netfunction"
													name="producta.netfunction" />下载 </label><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">开通时间：<span style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="producta.begintime" id="begintime"
													readonly="readonly" onclick="WdatePicker()" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">网址：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="producta.html" id="html"
													class="form-control" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">并发数：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="producta.concurrencylevel"
													id="concurrencylevel" class="form-control" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">网管账号：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="producta.username" id="ausername"
													class="form-control" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">网管密码：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="producta.password" id="apassword"
													class="form-control" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">备注：</label>
											<div class="col-sm-9">
												<textarea rows="5" cols="30" name="producta.remark"></textarea>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>	
					</div>	
				</div>
								<!-- A产品 -->
								<!-- B产品 -->
				<div id="bpro">
					<div class="baTopNo" id="bpro1">
						<span>微刊 </span>
					</div>
					<div class="baBody" id="bpro2">
						<div class="row form-body form-horizontal m-t">
							<div class="col-sm-6">
								<div class="ibox float-e-margins">
									<div class="col-md-12">
										<div class="form-group">
											<label class="col-sm-3 control-label" for="-NaN">资源类型：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<label class="checkbox-inline" for="sourcetype"> <input
													type="checkbox" value="1" id="sourcetype1"
													name="productb.sourcetype" checked="checked" />新闻</label> <label
													class="checkbox-inline" for="sourcetype"> <input
													type="checkbox" value="2" id="sourcetype2"
													name="productb.sourcetype" />通知 </label><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label" for="-NaN">服务方式：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<label class="checkbox-inline" for="servetype"> <input
													type="checkbox" value="1" id="servetype1"
													name="productb.servetype" checked="checked" />微信接口对接</label>
												<label class="checkbox-inline" for="servetype"> <input
													type="checkbox" value="2" id="servetype2"
													name="productb.servetype" />微信公共 号授权</label><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">运营方式：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<select class="form-control" name="productb.businesstype">
													<option value="1" selected="">自运营</option>
													<option value="2">代理运营</option>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">微刊地址：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="weixinaddress" id="weixinaddress"
													class="form-control" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">网管账号：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="productb.username" id="busername"
													class="form-control" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">网管密码：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="productb.password" id="bpassword"
													class="form-control" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">备注：</label>
											<div class="col-sm-9">
												<textarea rows="5" cols="30" name="productb.remark"></textarea>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>	
					</div>	
				</div>
								<!-- B产品 -->
								<!-- C产品 -->
				<div id="cpro">
					<div class="baTopNo" id="cpro1">
						<span>微博公共号 </span>
					</div>
					<div class="baBody" id="cpro2">
						<div class="row form-body form-horizontal m-t">
							<div class="col-sm-6">
								<div class="ibox float-e-margins">
									<div class="col-md-12">
										<div class="form-group">
											<label class="col-sm-3 control-label">网管账号：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="productc.username" id="cusername"
													class="form-control"  /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">网管密码：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="productc.password" id="cpassword"
													class="form-control" /><span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">备注：</label>
											<div class="col-sm-9">
												<textarea rows="5" cols="30" name="productc.remark"></textarea>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>	
					</div>	
				</div>
								<!-- C产品 -->
					
					<div class="baBody" id="baBodysubmit">
						<table>
							<tr class="bbD">
								<td class="td"></td>
								<td><input type="submit" value="确认" id="button" /> <input
									type="reset" value="重置" id="button" /></td>
							</tr>
						</table>
					</div>
				</form:form>
			</div>

			<!-- 上传广告页面样式end -->
		</div>
	</div>
	<script>
		$(function() {
			//产品显示
			$("#atype").on("click", function() {
				if (this.checked) {
					$("#apro").show();
				} else {
					$("#apro").hide();
				}
			});
			$("#btype").on("click", function() {
				if (this.checked) {
					$("#bpro").show();
				} else {
					$("#bpro").hide();
				}
			});
			$("#ctype").on("click", function() {
				if (this.checked) {
					$("#cpro").show();
				} else {
					$("#cpro").hide();
				}
			});
			//JS验证
			$("#amount").blur(
					function() {
						if (checkNeedscore($(this),1000,100000000,'金额不低于1000')
								&& minLength($(this), 4, '最小长度为4'))
								;
					});
			$("#ausername").blur(
					function() {
						if (required($(this), '用户名不能为空')
								&& minLength($(this), 4, '姓名最小长度为4')
								&& maxLength($(this), 20, '姓名最大长度为20'))
							;
					});
			$("#apassword").blur(
					function() {
						if (required($(this), '密码不能为空')
								&& minLength($(this), 4, '密码最小长度为4')
								&& maxLength($(this), 20, '密码最大长度为20'))
							;
					});
			$("#busername").blur(
					function() {
						if (required($(this), '用户名不能为空')
								&& minLength($(this), 4, '姓名最小长度为4')
								&& maxLength($(this), 20, '姓名最大长度为20'))
							;
					});
			$("#bpassword").blur(
					function() {
						if (required($(this), '密码不能为空')
								&& minLength($(this), 4, '密码最小长度为4')
								&& maxLength($(this), 20, '密码最大长度为20'))
							;
					});
			$("#cusername").blur(
					function() {
						if (required($(this), '用户名不能为空')
								&& minLength($(this), 4, '姓名最小长度为4')
								&& maxLength($(this), 20, '姓名最大长度为20'))
							;
					});
			$("#cpassword").blur(
					function() {
						if (required($(this), '密码不能为空')
								&& minLength($(this), 4, '密码最小长度为4')
								&& maxLength($(this), 20, '密码最大长度为20'))
							;
					});
			$("#oname").blur(
					function() {
						if (required($(this), '名称不能为空')
								&& minLength($(this), 2, '机构最小长度为2'))
							;
					});
			$("#autoComplete").blur(
					function() {
						if (required($(this), '机构名称不能为空')
								&& minLength($(this), 2, '机构最小长度为2'))
							;
					});
			$("#amount").blur(
					function() {
						if (required($(this), '金额不能为空')
								&& minLength($(this), 4, '最小为4位')
								&& maxLength($(this), 20, '最大长度为20'))
							;
					});
			 //验证日期（判断结束日期是否大于开始日期）日期格式为YY—MM—DD
			  function checkTime(){             
			  		var beginTime=$("#begindate").val();
			  		var endTime=$("#enddate").val();
			  		if(beginTime == "") {
			  		    alert("开始时间不能为空");
			  		    return false;
			  		}
			  		if(endTime == "") {
			  		    alert("结束时间不能为空");
			  		    return false;
			  		}
			  		var t1 = beginTime.replace("/"," ");
			  	    var t2 = endTime.replace("/"," ");
			  	    var   date1   =   new   Date(t1.replace("-","/"));
			  	    var   date2   =   new   Date(t2.replace("-","/"));
			  	    var   n     =   date1.getTime()   -   date2.getTime();
			  	    if(!(n<0)){
			  	  	  alert("结束时间要晚于开始时间");
			  	   	  return false;
			  	    }
			  	    return true;
				}  
			/* $("#signdate").blur(function() {
				if (required($(this), '时间不能为空'))
					;
			});
			$("#deadline").blur(function() {
				if (required($(this), '时间不能为空'))
					;
			});
			$("#begindate").blur(function() {
				if (required($(this), '时间不能为空'))
					;
			});
			$("#enddate").blur(
					function() {
						if (required($(this), '时间不能为空')
								&& checkStartLessEndDate($("#begindate"),
										$(this), '起始时间 不大于 日期结束时间'))
							;
					});
			$("#begintime").mouseup(function() {
				if (required($(this), '时间不能为空'))
					;
			}); */
			//暂时先不做网址判断
			$("#html").blur(function() {
				if (required($(this), '网址不能为空'))
					;
			});
			$("#concurrencylevel").blur(function() {
				if (required($(this), '不能为空'))
					;
			});
			$("#weixinaddress").blur(function() {
				if (required($(this), '地址不能为空'))
					;
			});
			$("#aset").blur(function() {
				if (required($(this), '不能为空'))
					;
			});
			$("#bset").blur(function() {
				if (required($(this), '不能为空'))
					;
			});
		});
		function checkform() {
			haveError = false; //全局错误信息变量, 如果有错误,变量值会变成ture  ,再验证完所有之后再判断,是否要提交表单
			var adisplay = $('#apro').css('display');
			var bdisplay = $('#bpro').css('display');
			var cdisplay = $('#cpro').css('display');
			$("#amount").blur();
			$("#bset").blur();
			$("#aset").blur();
			$("#oname").blur();
			$("#amount").blur();
			$("#autoComplete").blur();
			$("#signdate").mouseup();
			$("#deadline").mouseup();
			$("#begindate").mouseup();
			$("#enddate").mouseup();
			 if(adisplay != 'none'){
				 $("#ausername").blur();
				 $("#apassword").blur();
				 if($("input:checkbox[name*='netfunction']:checked").length == 0){
					 haveError = true;
				 }
				$("#begintime").mouseup();
				$("#html").blur();
				$("#concurrencylevel").blur();
			}
			if(bdisplay != 'none'){
				 $("#busername").blur();
				 $("#bpassword").blur();
				 if($("input:checkbox[name*='sourcetype']:checked").length == 0){
					 haveError = true;
				 }
				 if($("input:checkbox[name*='servetype']:checked").length == 0){
					 haveError = true;
				 }
				$("#weixinaddress").blur();
			} 
			if(cdisplay != 'none'){
				 $("#cusername").blur();
				 $("#cpassword").blur();
			}
			 if($("#atype").attr('checked') || $("#btype").attr('checked') || $("#ctype").attr('checked')){
				 haveError = false;
			 }else {haveError = true;}
			if (!haveError) {
				return true;
			} else {
				alert("请填写完整");
				return false;
			}
		}
	</script>

</body>
</html>